import xFetch, {
    get,
    post,
    postCustom
} from '../util/xFetch';
import ajax from '../util/ajax';
import qs from 'qs';
import Service from '../service';

export const menu = async (params) => post(`${Service.baseUrl}/earlywarn/login/queryMenu`, params);

export const Logout = async (params) => post(`${Service.baseUrl}/admin/login/logout`, params);

export const updatePwd = async (params) => post(`${Service.baseUrl}/earlywarn/user/updatePwdByUserId`, params);

// 用户登录
export const user = async ({
    mobile,
    code
}) => post(`${Service.baseUrl}/user/login/login`, {
    mobile,
    code
});
// 快递员登录
export const userkAdmin = async ({
    mobile,
    code
}) => post(`${Service.baseUrl}/express/login/login`, {
    mobile,
    code
});

// 管理员登录
export const userMAdmin = async ({
    mobile,
    code
}) => post(`${Service.baseUrl}/admin/login/mobile_login`, {
    mobile,
    code
});


export const register = async ({
    mobile,
    verify_code,
    type
}) => post(`${Service.baseUrl}/verify/verify`, {
    mobile,
    verify_code,
    type
});

export const sendCode = async ({
    mobile,
    type
}) => postCustom(`${Service.baseUrl}/
user/login/verify`, {
    mobile,
    // type
});

export const sendKCode = async ({
    mobile,
    type
}) => postCustom(`${Service.baseUrl}/
express/login/verify`, {
    mobile,
    // type
});


export const sendAdminCode = async ({
    mobile,
    type
}) => post(`${Service.baseUrl}/
admin/login/verify`, {
    mobile,
    // type
});





export const rePwd = async ({
    mobile,
    password_confirm,
    password,
    verify_code
}) => post(`${Service.baseUrl}/auth/findpassword`, {
    mobile,
    password_confirm,
    password,
    verify_code
});

export const queryStatistics = async (params) => post(`${Service.baseUrl}/admin/index/statistics`, params);
export const personalQuery = async (params) => post(`${Service.baseUrl}/admin/e_bike/index`, params);


export const update = async (params) => post(`${Service.baseUrl}/auth/register`, params);

export const queryarea = async (params) => get(`${Service.baseUrl}/tool/area`, params);


export const deviceList = async (params) => post(`${Service.baseUrl}/devices/index`, params);
export const devicesAction = async (params) => post(`${Service.baseUrl}/devices/action`, params);
export const receive = async (params) => post(`${Service.baseUrl}/devices/receive`, params);

const API = {
    query: `${Service.baseUrl}/admin/entity/list`, // 列表
    sendOrder: `${Service.baseUrl}/earlywarn/project/sendOrder`,
    instDetail: `${Service.baseUrl}/earlywarn/project/detail`, //详情
    sendOrderXml: `${Service.baseUrl}/earlywarn/project/sendOrderXml`,
    addProject: `${Service.baseUrl}/earlywarn/project/add`, // 添加
    search: `${Service.baseUrl}/admin/devices/search`, // 搜索
    save: `${Service.baseUrl}/earlywarn/project/bangRolePermission`,
    delete: `${Service.baseUrl}/admin/devices/delete`, // 删除


}
// 地图
export const query = async (params) => get(API.query, params)

// 企业的列表的接口
export const getCompany = async (params) => post(`${Service.baseUrl}/admin/tool/getCompany`, params);